﻿using System;
using System.Web.Mvc;
using TrainingManagerSystem.WebUI.Models;
using TrainingManagerSystem.WebUI.TrainingManagerSystemService;

namespace TrainingManagerSystem.WebUI.Controllers
{
    public class AccountCertificateController: Controller
    {
        //add by LyNQ
        private readonly TrainingManagerSystemModelClient _service = new TrainingManagerSystemModelClient();

        private readonly AccountCertificateModel _accountCertificateModel=new AccountCertificateModel();
        private string Account = Environment.UserName;

        public ViewResult Index() {
            ViewBag.Tree = _accountCertificateModel.Certificates();
            //ViewBag.Tree2 = _accountCertificateModel.Certificates();
            var accountCertificates = _accountCertificateModel.Search(50, 1, 0, null, null, null, null, null, null, true, 0);
            return View(accountCertificates);
        }

        public JsonResult SearchAjax(int pageSize, int currentPage, string accountName, string score, string certificateCategory, string employeeId, string certificateName, string certificateProvider, int node)
        {
            var acc = _accountCertificateModel.Search(pageSize, currentPage, node,employeeId,certificateProvider, certificateCategory, accountName, certificateName, score, true,0);
            return Json(acc);
        }

        //QuyenNTH
        [HttpPost]
        public JsonResult DetailCertificatePopup(int certificateId) {
            var data = _accountCertificateModel.CertificateDetailByCertificateId(certificateId);
            return Json(data);
        }
    }
}